package gamejam.platformer;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;

public class Tile {
	private Image image;
	private Rectangle bounds;
	public Tile(Image img, int x, int y) {
		this(img, x, y, img.getWidth(null), img.getHeight(null));
	}
	public Tile(Image img, int x, int y, int width, int height) {
		image = img;
		bounds = new Rectangle(x, y, width, height);
	}
	public void draw(Graphics g, int xOffset, int yOffset) {
		g.drawImage(image, bounds.x - xOffset, bounds.y - yOffset, bounds.width, bounds.height, null);
	}
	public void drawBoundingBox(Graphics g, int xOffset, int yOffset) {
		g.drawRect(bounds.x - xOffset, bounds.y - yOffset, bounds.width - 1, bounds.height - 1);
	}
	public Rectangle getBounds() {
		return bounds;
	}
	public int getHeight() {
		return bounds.height;
	}
	public Image getImage() {
		return image;
	}
	public int getWidth() {
		return bounds.width;
	}
	public int getX() {
		return bounds.x;
	}
	public int getY() {
		return bounds.y;
	}
	public void setBounds(Rectangle newBounds) {
		bounds = newBounds;
	}
	public void setX(int x) {
		bounds.x = x;
	}
	public void setY(int y) {
		bounds.y = y;
	}
	public void tick() {
	}
	public String toString() {
		return String.format("%s[x=%s, y=%s, w=%s, h=%s]", this.getClass().getCanonicalName(),
				bounds.x, bounds.y, bounds.width, bounds.height);
	}
}
